using System.ComponentModel.DataAnnotations;

namespace CoreManager.Models.DTOs
{
    /// <summary>
    /// 菜单响应DTO
    /// </summary>
    public class MenuDto
    {
        /// <summary>
        /// 菜单ID
        /// </summary>
        public int Id { get; set; }

        /// <summary>
        /// 菜单名称
        /// </summary>
        public string Name { get; set; } = string.Empty;

        /// <summary>
        /// 菜单标识/路由名称
        /// </summary>
        public string Key { get; set; } = string.Empty;

        /// <summary>
        /// 菜单路径
        /// </summary>
        public string? Path { get; set; }

        /// <summary>
        /// 菜单图标
        /// </summary>
        public string? Icon { get; set; }

        /// <summary>
        /// 父级菜单ID
        /// </summary>
        public int? ParentId { get; set; }

        /// <summary>
        /// 菜单类型 (1:目录 2:菜单 3:按钮)
        /// </summary>
        public int Type { get; set; }

        /// <summary>
        /// 排序号
        /// </summary>
        public int Sort { get; set; }

        /// <summary>
        /// 是否隐藏
        /// </summary>
        public bool Hidden { get; set; }

        /// <summary>
        /// 组件路径
        /// </summary>
        public string? Component { get; set; }

        /// <summary>
        /// 页面标题
        /// </summary>
        public string? Title { get; set; }

        /// <summary>
        /// 面包屑隐藏
        /// </summary>
        public bool BreadcrumbHidden { get; set; }

        /// <summary>
        /// 标签页可关闭
        /// </summary>
        public bool Closable { get; set; }

        /// <summary>
        /// 缓存页面
        /// </summary>
        public bool KeepAlive { get; set; }

        /// <summary>
        /// 固定标签页
        /// </summary>
        public bool Affix { get; set; }

        /// <summary>
        /// 菜单状态 (1:启用 0:禁用)
        /// </summary>
        public int Status { get; set; }

        /// <summary>
        /// 菜单描述
        /// </summary>
        public string? Description { get; set; }

        /// <summary>
        /// 权限标识
        /// </summary>
        public string? Permission { get; set; }

        /// <summary>
        /// 创建时间
        /// </summary>
        public DateTime CreateTime { get; set; }

        /// <summary>
        /// 更新时间
        /// </summary>
        public DateTime? UpdateTime { get; set; }

        /// <summary>
        /// 子菜单列表
        /// </summary>
        public List<MenuDto> Children { get; set; } = new List<MenuDto>();
    }

    /// <summary>
    /// 菜单创建请求DTO
    /// </summary>
    public class CreateMenuDto
    {
        /// <summary>
        /// 菜单名称
        /// </summary>
        [Required(ErrorMessage = "菜单名称不能为空")]
        [MaxLength(100, ErrorMessage = "菜单名称长度不能超过100个字符")]
        public string Name { get; set; } = string.Empty;

        /// <summary>
        /// 菜单标识/路由名称
        /// </summary>
        [Required(ErrorMessage = "菜单标识不能为空")]
        [MaxLength(100, ErrorMessage = "菜单标识长度不能超过100个字符")]
        public string Key { get; set; } = string.Empty;

        /// <summary>
        /// 菜单路径
        /// </summary>
        [MaxLength(200, ErrorMessage = "菜单路径长度不能超过200个字符")]
        public string? Path { get; set; }

        /// <summary>
        /// 菜单图标
        /// </summary>
        [MaxLength(100, ErrorMessage = "菜单图标长度不能超过100个字符")]
        public string? Icon { get; set; }

        /// <summary>
        /// 父级菜单ID
        /// </summary>
        public int? ParentId { get; set; }

        /// <summary>
        /// 菜单类型 (1:目录 2:菜单 3:按钮)
        /// </summary>
        [Range(1, 3, ErrorMessage = "菜单类型必须在1-3之间")]
        public int Type { get; set; } = 2;

        /// <summary>
        /// 排序号
        /// </summary>
        public int Sort { get; set; } = 0;

        /// <summary>
        /// 是否隐藏
        /// </summary>
        public bool Hidden { get; set; } = false;

        /// <summary>
        /// 组件路径
        /// </summary>
        [MaxLength(200, ErrorMessage = "组件路径长度不能超过200个字符")]
        public string? Component { get; set; }

        /// <summary>
        /// 页面标题
        /// </summary>
        [MaxLength(100, ErrorMessage = "页面标题长度不能超过100个字符")]
        public string? Title { get; set; }

        /// <summary>
        /// 面包屑隐藏
        /// </summary>
        public bool BreadcrumbHidden { get; set; } = false;

        /// <summary>
        /// 标签页可关闭
        /// </summary>
        public bool Closable { get; set; } = true;

        /// <summary>
        /// 缓存页面
        /// </summary>
        public bool KeepAlive { get; set; } = false;

        /// <summary>
        /// 固定标签页
        /// </summary>
        public bool Affix { get; set; } = false;

        /// <summary>
        /// 菜单状态 (1:启用 0:禁用)
        /// </summary>
        [Range(0, 1, ErrorMessage = "菜单状态必须为0或1")]
        public int Status { get; set; } = 1;

        /// <summary>
        /// 菜单描述
        /// </summary>
        [MaxLength(500, ErrorMessage = "菜单描述长度不能超过500个字符")]
        public string? Description { get; set; }

        /// <summary>
        /// 权限标识
        /// </summary>
        [MaxLength(200, ErrorMessage = "权限标识长度不能超过200个字符")]
        public string? Permission { get; set; }
    }

    /// <summary>
    /// 菜单更新请求DTO
    /// </summary>
    public class UpdateMenuDto
    {
        /// <summary>
        /// 菜单名称
        /// </summary>
        [Required(ErrorMessage = "菜单名称不能为空")]
        [MaxLength(100, ErrorMessage = "菜单名称长度不能超过100个字符")]
        public string Name { get; set; } = string.Empty;

        /// <summary>
        /// 菜单标识/路由名称
        /// </summary>
        [Required(ErrorMessage = "菜单标识不能为空")]
        [MaxLength(100, ErrorMessage = "菜单标识长度不能超过100个字符")]
        public string Key { get; set; } = string.Empty;

        /// <summary>
        /// 菜单路径
        /// </summary>
        [MaxLength(200, ErrorMessage = "菜单路径长度不能超过200个字符")]
        public string? Path { get; set; }

        /// <summary>
        /// 菜单图标
        /// </summary>
        [MaxLength(100, ErrorMessage = "菜单图标长度不能超过100个字符")]
        public string? Icon { get; set; }

        /// <summary>
        /// 父级菜单ID
        /// </summary>
        public int? ParentId { get; set; }

        /// <summary>
        /// 菜单类型 (1:目录 2:菜单 3:按钮)
        /// </summary>
        [Range(1, 3, ErrorMessage = "菜单类型必须在1-3之间")]
        public int Type { get; set; } = 2;

        /// <summary>
        /// 排序号
        /// </summary>
        public int Sort { get; set; } = 0;

        /// <summary>
        /// 是否隐藏
        /// </summary>
        public bool Hidden { get; set; } = false;

        /// <summary>
        /// 组件路径
        /// </summary>
        [MaxLength(200, ErrorMessage = "组件路径长度不能超过200个字符")]
        public string? Component { get; set; }

        /// <summary>
        /// 页面标题
        /// </summary>
        [MaxLength(100, ErrorMessage = "页面标题长度不能超过100个字符")]
        public string? Title { get; set; }

        /// <summary>
        /// 面包屑隐藏
        /// </summary>
        public bool BreadcrumbHidden { get; set; } = false;

        /// <summary>
        /// 标签页可关闭
        /// </summary>
        public bool Closable { get; set; } = true;

        /// <summary>
        /// 缓存页面
        /// </summary>
        public bool KeepAlive { get; set; } = false;

        /// <summary>
        /// 固定标签页
        /// </summary>
        public bool Affix { get; set; } = false;

        /// <summary>
        /// 菜单状态 (1:启用 0:禁用)
        /// </summary>
        [Range(0, 1, ErrorMessage = "菜单状态必须为0或1")]
        public int Status { get; set; } = 1;

        /// <summary>
        /// 菜单描述
        /// </summary>
        [MaxLength(500, ErrorMessage = "菜单描述长度不能超过500个字符")]
        public string? Description { get; set; }

        /// <summary>
        /// 权限标识
        /// </summary>
        [MaxLength(200, ErrorMessage = "权限标识长度不能超过200个字符")]
        public string? Permission { get; set; }
    }

    /// <summary>
    /// 菜单查询请求DTO
    /// </summary>
    public class MenuQueryDto
    {
        /// <summary>
        /// 菜单名称（模糊查询）
        /// </summary>
        public string? Name { get; set; }

        /// <summary>
        /// 菜单类型 (1:目录 2:菜单 3:按钮)
        /// </summary>
        public int? Type { get; set; }

        /// <summary>
        /// 菜单状态 (1:启用 0:禁用)
        /// </summary>
        public int? Status { get; set; }

        /// <summary>
        /// 父级菜单ID
        /// </summary>
        public int? ParentId { get; set; }
    }
}